package babo.cd.physicalexperiment.activity;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.webkit.SslErrorHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.aliyun.player.AliPlayer;
import com.aliyun.player.AliPlayerFactory;
import com.aliyun.player.IPlayer;
import com.aliyun.player.bean.ErrorInfo;
import com.aliyun.player.nativeclass.PlayerConfig;
import com.aliyun.player.source.UrlSource;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.cicada.player.utils.Logger;
import com.lxj.xpopup.XPopup;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.File;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

import babo.cd.physicalexperiment.BaseActivity;
import babo.cd.physicalexperiment.R;
import babo.cd.physicalexperiment.app.MyApplication;
import babo.cd.physicalexperiment.bean.ShiyanCommitBean;
import babo.cd.physicalexperiment.data.MyEnventData;
import babo.cd.physicalexperiment.data.RecordData;
import babo.cd.physicalexperiment.databinding.ActivityMaikerxunBinding;
import babo.cd.physicalexperiment.dialog.AddHistoryDialog;
import babo.cd.physicalexperiment.dialog.DialogCommon;
import babo.cd.physicalexperiment.dialog.TiaozhengmkexDialog;
import babo.cd.physicalexperiment.utils.OKCallback;
import babo.cd.physicalexperiment.utils.OkUtils;
import babo.cd.physicalexperiment.utils.Out;
import babo.cd.physicalexperiment.utils.SimpleUtils;
import babo.cd.physicalexperiment.utils.Tool;
import babo.cd.physicalexperiment.utils.URLS;

import static babo.cd.physicalexperiment.activity.ImagePagerActivity.EXTRA_IMAGE_INDEX;
import static babo.cd.physicalexperiment.activity.ImagePagerActivity.EXTRA_IMAGE_URLS;

public class MaikeerxunActivity extends BaseActivity {
    ActivityMaikerxunBinding binding;
    AddHistoryDialog addHistoryDialog;
    TiaozhengmkexDialog tiaozhengmkexDialog;
    List<RecordData> datas=new ArrayList<>();
    BaseQuickAdapter adapter;
    DialogCommon dialogCommon;
    DialogCommon dialogChooseType;
    private String deviceId="";
    private String apid="";
    AliPlayer aliPlayer;
    Surface surfaceView;
    private String currentLarurl="";
    private String currentSmall="";
    String url="";
    ShiyanCommitBean commitBean;
    CountDownTimer countDownTimer;
    Timer timer;
    private String playerUrl="";
    private String pushUrl="";
    private String didfq="";
    File filect,filewt;
    private TimerTask task;
    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            doLoop();
            super.handleMessage(msg);
        }

    };
    private void doLoop() {
        OkUtils.GetOk(URLS.doLoop+"?deviceId="+didfq,new OKCallback(context){
            @Override
            public void Sucess(String str) {
                super.Sucess(str);
                Out.out("轮询一次："+str);
            }

        });
    }

    @Override
    protected View bindView() {
        binding=ActivityMaikerxunBinding.inflate(getLayoutInflater());
        return binding.getRoot();

    }

    @Override
    protected void initView() {
        binding.rcv.setLayoutManager(new LinearLayoutManager(context));
        adapter=new BaseQuickAdapter(R.layout.item_shiyandata,datas) {
            @Override
            protected void convert(BaseViewHolder helper, Object item) {
                bindConvert(helper,(RecordData)item);
            }

        };
        binding.rcv.setAdapter(adapter);
        binding.svPlay.setWebViewClient(new ExampleWebViewClient());
        binding.svPlay.getSettings().setJavaScriptEnabled(true);
        if (Build.VERSION.SDK_INT >= 21) {
            binding.svPlay.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
        }
    }

    private void bindConvert(BaseViewHolder helper, RecordData item) {
        TextView txcutiao=helper.getView(R.id.txcutiao);
        TextView txweitiao=helper.getView(R.id.txweitiao);
        TextView txjsz=helper.getView(R.id.txjsz);
        TextView tx_caozuo=helper.getView(R.id.tx_caozuo);
        TextView txxuhao=helper.getView(R.id.txxuhao);
        txcutiao.setText(item.getLargeValue());
        txweitiao.setText(item.getSmallValue());
        txjsz.setText(item.getResultValue());
        int positon=helper.getAdapterPosition();
        txxuhao.setText((positon+1)+"");

        datas.get(positon).setOrderNo((positon+1)+"");

        tx_caozuo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                doDelete(positon);
            }
        });
    }

    private void doDelete(int adapterPosition) {
        dialogCommon=new DialogCommon(context);
        dialogCommon.setTitle("提示");
        dialogCommon.setMessage("确定删除该记录吗？");
        dialogCommon.setConfirm("确定", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialogCommon.dismiss();
                datas.remove(adapterPosition);
                adapter.notifyDataSetChanged();
                if (datas.size()==0){
                    binding.lltt.setVisibility(View.GONE);
                    binding.txZwjl.setVisibility(View.VISIBLE);
                }
            }
        });
        dialogCommon.setCancel("取消", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
             dialogCommon.dismiss();
            }
        });
        dialogCommon.show();

    }

    @Override
    protected void loadData() {


        didfq=getIntent().getStringExtra("didfq");
        deviceId=getIntent().getStringExtra("did");
        playerUrl=getIntent().getStringExtra("purl");
        pushUrl=getIntent().getStringExtra("pushurl");
        apid=getIntent().getStringExtra("apid");
        initWebView();
        String role= MyApplication.getInstance().getUserBaseInfo().getRole().toUpperCase();
        if (role.contains("ADMIN")){
            binding.txyqjz.setVisibility(View.VISIBLE);
        }else{
            binding.txyqjz.setVisibility(View.GONE);
        }

        countDownTimer= new CountDownTimer(30*60*1000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                String value = String.valueOf((int) (millisUntilFinished / 1000));
                int syms=(int) (millisUntilFinished / 1000);


                int fz= syms/60;
                int mz=syms%60;

                String sfz="";
                String smz="";
                if (fz<10){
                    sfz="0"+fz;
                }else{
                    sfz=fz+"";
                }
                if (mz<10){
                    smz="0"+mz;
                }else{
                    smz=mz+"";
                }
                binding.txTimedjs.setText("实验剩余时间: "+sfz+":"+smz);

//                mTvValue.setText(value);
            }

            @Override
            public void onFinish() {

                Out.toast(context,"实验时间已到！");
                finish();
            }
        };
        countDownTimer.start();
        timer=new Timer();
        task = new TimerTask() {
            @Override
            public void run() {
                Message message = new Message();
                message.what = 1;
                handler.sendMessage(message);
            }
        };
        timer.schedule(task, 1000, 30000);
        commitBean=new ShiyanCommitBean();

        dialogChooseType=new DialogCommon(context);
        dialogChooseType.setTitle("提示");
        dialogChooseType.setMessage("请选择开始实验视频流线路");
        dialogChooseType.setConfirm("远程线路", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(MyEnventData.getInstance("startshiyanmkex@"+deviceId+"@remote"+"@"+pushUrl));
                dialogChooseType.dismiss();
                binding.svPlay.setVisibility(View.GONE);
                binding.svPlayyuancheng.setVisibility(View.VISIBLE);
                initPlayer();
                doStartDIngyueTupian();
//                doInitLivePlay();
            }
        });
        dialogChooseType.setCancel("本地线路",new View.OnClickListener(){
            @Override
            public void onClick(View v) {
                binding.svPlay.setVisibility(View.VISIBLE);
                binding.svPlayyuancheng.setVisibility(View.GONE);
                EventBus.getDefault().post(MyEnventData.getInstance("startshiyanmkex@"+deviceId+"@local"+"@"+pushUrl));
                dialogChooseType.dismiss();
                doStartDIngyueTupian();

            }
        });
        dialogChooseType.show();

//        initPlayer();



    }

    private void doStartDIngyueTupian() {
        EventBus.getDefault().post(MyEnventData.getInstance("dingyuetupian@"+deviceId));

    }

    private void initWebView() {
        binding.svPlay.setWebViewClient(new ExampleWebViewClient());
        binding.svPlay.getSettings().setJavaScriptEnabled(true);
        binding.svPlay.getSettings().setMediaPlaybackRequiresUserGesture(false);
        binding.svPlay.getSettings().setLoadWithOverviewMode(true);
        binding.svPlay.getSettings().setUseWideViewPort(true);

        binding.svPlay.getSettings().setPluginState(WebSettings.PluginState.ON);
        binding.svPlay.getSettings().setAllowFileAccess(true);
        binding.svPlay.getSettings().setSupportZoom(true);
        binding.svPlay.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

        if (Build.VERSION.SDK_INT >= 21) {
            binding.svPlay.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
        }


    }

    private void initPlayer() {
        System.loadLibrary("RtsSDK");
        aliPlayer= AliPlayerFactory.createAliPlayer(this);
        PlayerConfig config = aliPlayer.getConfig();
//设置最大延迟为1秒，延迟控制由ARTC控制
        config.mMaxDelayTime = 1000;
//设置播放器启播缓存为10毫秒，数据控制由ARTC控制。
        config.mHighBufferDuration = 10;
        config.mStartBufferDuration = 10;
//其他设置
//给播放器加载配置
        aliPlayer.setConfig(config);
        Logger.getInstance(context).enableConsoleLog(true);
        Logger.getInstance(context).setLogLevel(Logger.LogLevel.AF_LOG_LEVEL_TRACE);

        //     SurfaceHolder holder=   binding.svPlay.getHolder();

//
//        //得到视图的状态
//        holder.addCallback(new SurfaceHolder.Callback() {
//            //视图销毁
//            @Override
//            public void surfaceDestroyed(SurfaceHolder holder) {
//                // TODO Auto-generated method stub
//                aliPlayer.setDisplay(holder);
//            }
//            //视图创建完成
//            @Override
//            public void surfaceCreated(SurfaceHolder holder) {
//                // TODO Auto-generated method stub
//                Out.out("准备好AAA1");
//                aliPlayer.setDisplay(holder);
//                aliPlayer.setSurface(holder.getSurface());
//                aliPlayer.setOnErrorListener(new IPlayer.OnErrorListener() {
//                    @Override
//                    public void onError(ErrorInfo errorInfo) {
//                        //出错事件
//                        Out.out("错粗：="+errorInfo.getMsg());
//                        Out.out("错粗22：="+errorInfo.getExtra());
//                    }
//                });
//        long duration = androidMediaPlayer.getDuration();
//        try {

//                    path="http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8";

//                    UrlSource urlSource=new UrlSource();
//                    urlSource.setUri(playerUrl);
//                    //设置资源
//                    aliPlayer.setDataSource(urlSource);
//                    //异步准备
//                    aliPlayer.prepare();
//                    //播放
//                    aliPlayer.setOnPreparedListener(new IPlayer.OnPreparedListener() {
//                        @Override
//                        public void onPrepared() {
//                            Out.out("视频准备好");
//                            aliPlayer.start();
//                        }
//                    });
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//
//            }
//            //视图改变
//            @Override
//            public void surfaceChanged(SurfaceHolder holder, int format, int width,
//                                       int height) {
//                aliPlayer.redraw();
//
//            }
//        });
    }
    private void doInitLivePlay() {
        Out.out("开始拉流AAA");

        Logger.getInstance(context).enableConsoleLog(true);
        Logger.getInstance(context).setLogLevel(Logger.LogLevel.AF_LOG_LEVEL_TRACE);
//        EventBus.getDefault().post(MyEnventData.getInstance("startshiyanmkex@"+deviceId));

        SurfaceView surfaceView=new SurfaceView(context);
        binding.svPlayyuancheng.addView(surfaceView);
        SurfaceHolder holder=  surfaceView.getHolder();


        //得到视图的状态
        holder.addCallback(new SurfaceHolder.Callback() {
            //视图销毁
            @Override
            public void surfaceDestroyed(SurfaceHolder holder) {
                // TODO Auto-generated method stub
                aliPlayer.setDisplay(holder);
            }
            //视图创建完成
            @Override
            public void surfaceCreated(SurfaceHolder holder) {
                // TODO Auto-generated method stub
                Out.out("准备好AAA1");
                aliPlayer.setDisplay(holder);
                aliPlayer.setSurface(holder.getSurface());
                aliPlayer.setOnErrorListener(new IPlayer.OnErrorListener() {
                    @Override
                    public void onError(ErrorInfo errorInfo) {
                        //出错事件
                        Out.out("错粗：="+errorInfo.getMsg());
                        Out.out("错粗22：="+errorInfo.getExtra());
                    }
                });
//        long duration = androidMediaPlayer.getDuration();
                try {
                    String path="artc://xhapp.cdbfbt.cn/555/555?auth_key=1623554479-0-0-1c73cef9d3744a0db57e143a74151f26";


                    path=playerUrl;
                    Out.out("推流地址=="+path);
//                    path="http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8";

                    UrlSource urlSource=new UrlSource();
                    urlSource.setUri(path);
                    //设置资源
                    aliPlayer.setDataSource(urlSource);
                    //异步准备
                    aliPlayer.prepare();
                    //播放
                    aliPlayer.setOnPreparedListener(new IPlayer.OnPreparedListener() {
                        @Override
                        public void onPrepared() {
                            Out.out("视频准备好");
                            aliPlayer.start();
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                    Out.out("推流错误=="+e.getMessage());
                }

            }
            //视图改变
            @Override
            public void surfaceChanged(SurfaceHolder holder, int format, int width,
                                       int height) {
                aliPlayer.redraw();

            }
        });



    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        try {
//            aliPlayer.stop();
//            aliPlayer.release();
//            aliPlayer=null;
        }catch (Exception ex){}

    }

    @Override
    public void leftClick() {
        super.leftClick();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode==KeyEvent.KEYCODE_BACK){
            doFagnqi();
        }
        if (keyCode==KeyEvent.KEYCODE_HOME){
            doFagnqi();
        }
            return  true;
    }

    @Override
    public void setListener() {
        super.setListener();


        binding.ivCutiao.setOnClickListener(v -> {
            if (filect==null){
                return;
            }

            String [] urls={filect.getAbsolutePath()};
            binding.vRedcutiao.setVisibility(View.GONE);
            Intent intent=new Intent(context,ImagePagerActivity.class);
            intent.putExtra(EXTRA_IMAGE_INDEX,0);
            intent.putExtra(EXTRA_IMAGE_URLS,urls);
            startActivity(intent);
        });
        binding.ivWeitiao.setOnClickListener(v -> {
            if (filewt==null){
                return;
            }

            String [] urls={filewt.getAbsolutePath()};
            binding.vRedweitiao.setVisibility(View.GONE);
            Intent intent=new Intent(context,ImagePagerActivity.class);
            intent.putExtra(EXTRA_IMAGE_INDEX,0);
            intent.putExtra(EXTRA_IMAGE_URLS,urls);
            startActivity(intent);
        });
        binding.txyqjz.setOnClickListener(view -> {
            Intent intent=new Intent(context,YiqiJiaozhunActivity.class);
            if (TextUtils.isEmpty(url)){
                intent.putExtra("purl",playerUrl);
                intent.putExtra("tpe",1);
            }else{
                intent.putExtra("purl",url);
                intent.putExtra("type",0);
            }
            intent.putExtra("did",deviceId);
            startActivity(intent);
        });
     binding.ivAdd.setOnClickListener(view -> {
         doAddhistory();
     });
     binding.txFangqi.setOnClickListener(v -> {
         doFagnqi();
     });
     binding.txSubmit.setOnClickListener(v -> {
         doComit();
     });
     binding.txbtantzjd.setOnClickListener(view -> {
         tiaozhengmkexDialog=new TiaozhengmkexDialog(this);
         new XPopup.Builder(context)
                 .dismissOnTouchOutside(false)
                 .asCustom(tiaozhengmkexDialog)
                 .show();
     });
     binding.topbar.getIm_back().setOnClickListener(v -> {
         doFagnqi();
     });

    }

    private void doComit() {
        dialogCommon=new DialogCommon(context);
        dialogCommon.setTitle("提示");
        dialogCommon.setMessage("本次实验共添加"+datas.size()+"条数据记录，确认要完成实验吗？");
        dialogCommon.setConfirm("确定", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialogCommon.dismiss();
                doCommit();
            }
        });
        dialogCommon.setCancel("取消", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialogCommon.dismiss();
            }
        });
        dialogCommon.show();
    }

    private void doFagnqi() {
        dialogCommon=new DialogCommon(context);
        dialogCommon.setTitle("提示");
        dialogCommon.setMessage("实验未完成，确定要放弃本次实验？");
        dialogCommon.setConfirm("确定", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialogCommon.dismiss();
               doFq();
            }
        });
        dialogCommon.setCancel("取消", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialogCommon.dismiss();
            }
        });
        dialogCommon.show();
    }
    private void doCommit() {
        commitBean.setAppointmentId(apid);
        commitBean.setDeviceId(didfq);
        commitBean.setResult("1");
        commitBean.setRecords(datas);
        String jsondata=gson.toJson(commitBean);
        LinkedHashMap map=new LinkedHashMap();
        map.put("data",jsondata);
        Out.out("完成实验jsdondata=="+jsondata);
        OkUtils.performByJson23(context, URLS.commitshiyan,jsondata,2,new OKCallback(context){
            @Override
            public void Sucess(String str) {
                super.Sucess(str);
                Out.toast(context,"数据上传成功！");
                EventBus.getDefault().post(MyEnventData.getInstance("endshiyanmkex@"+deviceId));
                setResult(81);
                finish();
            }
        });

    }

    private void doFq() {
        commitBean.setAppointmentId(apid);
        commitBean.setDeviceId(didfq);
        commitBean.setResult("2");
        commitBean.setRecords(datas);
        String jsondata=gson.toJson(commitBean);
        LinkedHashMap map=new LinkedHashMap();
        map.put("data",jsondata);
        OkUtils.performByJson23(context, URLS.commitshiyan,jsondata,2,new OKCallback(context){
            @Override
            public void Sucess(String str) {
                super.Sucess(str);
                EventBus.getDefault().post(MyEnventData.getInstance("giveupshiyanmkex@"+deviceId));
                finish();
            }
        });

    }

    private void doAddhistory() {
        if (filect==null||filewt==null){
            Out.toast(context,"请调节相机位置获取对应图片！");
            return;
        }
        addHistoryDialog=new AddHistoryDialog(this,currentLarurl,currentSmall,filect,filewt);
        new XPopup.Builder(context)
                .dismissOnTouchOutside(true)
                .asCustom(addHistoryDialog)
                .show();
    }
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onGetMessage(MyEnventData message) {
        String msg=message.message;
//        if (msg.startsWith("gundong@")){
//            msg=msg.replace("gundong@","");
//            String[] ss=msg.split("@");
//            String ct=ss[0];
//            String wt=ss[1];
//
//            EventBus.getDefault().post(MyEnventData.getInstance("gundong@"+ct+"@"+wt));
//        }


        if (msg.startsWith("showimg@")){//粗调
            msg=msg.replace("showimg@","");

            Out.out("显示粗调返回图片AAA");
            final  String mm=msg;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    hd.post(new Runnable() {
                        @Override
                        public void run() {
                            Bitmap bitmap= Tool.stringToBitmap(mm);
                            Out.out("显示粗调返回图片BBB");
                            binding.ivCutiao.setBackgroundResource(0);
                            binding.vRedcutiao.setVisibility(View.VISIBLE);
                            try {
                               filect= SimpleUtils.save2Album2(context, bitmap);
                                Glide.with(context).load(bitmap).into(binding.ivCutiao);
                                Out.out("显示粗调图片地址："+filect.getAbsolutePath());
                                binding.ivCutiao.setImageURI(Uri.fromFile(filect));
                            }catch (Exception ex){
                                ex.printStackTrace();
                            }

                        }
                    });

                }
            }).start();



        }
        if (msg.startsWith("showimgqd@")){
            msg=msg.replace("showimgqd@","");


            final  String mm=msg;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    hd.post(new Runnable() {
                        @Override
                        public void run() {
                            Out.out("显示微调返回图片AAA");
                            Bitmap bitmap= Tool.stringToBitmap(mm);
                            binding.ivWeitiao.setBackgroundResource(0);
                            binding.vRedweitiao.setVisibility(View.VISIBLE);
                            try {
                                Glide.with(context).load(bitmap).into(binding.ivWeitiao);
                                filewt= SimpleUtils.save2Album2(context, bitmap);
                                Out.out("图片路径微调："+filewt);
                            }catch (Exception ex){
                                ex.printStackTrace();
                            }

                        }
                    });

                }
            }).start();








        }

        if (msg.equals("playliveremote@")){
            Out.out("处理视频");
            doInitLivePlay();

        }
        if (msg.startsWith("playlivelocal@")){
             url=msg.replace("playlivelocal@","");
            Out.out("视频地址："+url);
            binding.svPlay.loadUrl(url);
        }
        if (msg.startsWith("tiaozhengmkex@")){
            msg=msg.replace("tiaozhengmkex@","");
            String[] ss=msg.split("@");

            String ctznew=ss[0];

            String wtznew=ss[1];

            Out.out("接收粗调="+ctznew+"==="+wtznew);

            DecimalFormat decimalFormat = new DecimalFormat("0.0000");

            BigDecimal newwz = new BigDecimal(wtznew).multiply(new BigDecimal(0.0001));


            BigDecimal newcz = new BigDecimal(ctznew).multiply(new BigDecimal(0.01));






            BigDecimal distancect =newcz;

            distancect=new BigDecimal(decimalFormat.format(distancect));


            BigDecimal distancewt=newwz;
            distancewt=new BigDecimal(decimalFormat.format(distancewt));




Out.out("distancectwz="+distancect+"  ====="+distancewt);

            binding.txKedu.setText("粗调值："+decimalFormat.format(newcz)+"mm");
            binding.txKedu2.setText("微调值："+decimalFormat.format(newwz)+"mm");
            EventBus.getDefault().post(MyEnventData.getInstance("mkexctwt@"+distancect+"@"+distancewt+"@"+deviceId));




        }
        if (msg.startsWith("addhistory@")){
            msg=msg.replace("addhistory@","");
            Out.out("新增一条数据："+msg);
            RecordData recordData=gson.fromJson(msg,RecordData.class);
            datas.add(recordData);
            adapter.notifyDataSetChanged();
            binding.txZwjl.setVisibility(View.GONE);
            binding.lltt.setVisibility(View.VISIBLE);
        }

    }
    private class ExampleWebViewClient extends WebViewClient {
        @Override
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
            handler.proceed();
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onLoadResource(WebView view, String url) {
            super.onLoadResource(view, url);
        }
    }
}
